package Euclid;

import org.antlr.runtime.ANTLRStringStream;
import org.antlr.runtime.CommonTokenStream;
import org.antlr.runtime.RecognitionException;

/**
 * 
 * @author Jon Ludwig
 *
 */
public class EuclidEngine {
	
	public EuclidParser parser;
	
	public EuclidEngine() {
		ANTLRStringStream i = new ANTLRStringStream("\n");
	    EuclidLexer lexer = new EuclidLexer(i);
	    CommonTokenStream tokens = new CommonTokenStream(lexer);
	    
	    parser = new EuclidParser(tokens);
	}
	
	public VarType calculate(String input) throws RecognitionException
	{
		ANTLRStringStream i = new ANTLRStringStream(input+"\n");
	    EuclidLexer lexer = new EuclidLexer(i);
	    CommonTokenStream tokens = new CommonTokenStream(lexer);
	    
	   	parser.setTokenStream(tokens);
	    
	    // TODO: start a separate thread
	    VarType v = parser.stat();
	    
	    return v;
	}
	
	public static void main(String[] args) {
		if (args.length < 1) {
			System.out.println("usage: java EuclidEngine equation");
			return;
		}
		
		String eq = args[0];
		
		
	}

}
